package com.xposed.openfire.smack.utils;

import android.content.Context;
import android.os.Looper;
import android.widget.Toast;

/**
 * Created by Administrator on 2018/3/10.
 */

public class ToastUtil {

    private static Toast toast;

    public static void showToast(Context context, String content) {
        if (toast == null) {
            toast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        } else {
            toast.setText(content);
        }
        toast.show();
    }
    public static void showToastLong(Context context, String content) {
            toast = Toast.makeText(context, content, Toast.LENGTH_LONG);
            toast.show();
    }
    public static void showToastOnUi(Context context, String content) {
         Looper.prepare();
         Toast.makeText(context, content, Toast.LENGTH_SHORT).show();
         Looper.loop();
    }
    public static void hideToast(){
        if (toast != null ) {
            toast.cancel();
        }
    }
}
